<?php

/**
 * This form allows a user to 
 * @author ovo
 *
 */
 class Admin_Form_addCourse extends Zend_Dojo_Form {
 	
 	
 	public function __construct($options = null){	
 		
	parent::__construct($options);
	Zend_Dojo::enableForm($this);
	 
	
	$AllSchool = new Admin_Model_DbTable_School();
	 $arr = $AllSchool->getSchools();
	 
	/**
	 * This gets all the schools from the school table.
	 * @var unknown_type
	 */
	$schools = new Zend_Dojo_Form_Element_FilteringSelect('school');
	$schools->setLabel('Select school:');
	
	$schools->addValidator('NotEmpty');
	foreach ($arr as $school){
   $schools->addMultiOption($school->id, $school->name);
	}
	
	
	
	$AllDepts = new Admin_Model_DbTable_Department();
	$arr = $AllDepts->fetchAll();
	

	/**
	 * This gets all the departments from the departments table
	 * @var unknown_type
	 */
	$dept = new Zend_Dojo_Form_Element_FilteringSelect('dept');
	$dept->setLabel('Select Department:');
	$dept->setAutocomplete(true);
	$dept->addValidator('NotEmpty');
	foreach ($arr as $depts){
		$dept->addMultiOption($depts->id, $depts->name);
	}
	
	$Allcats = new Admin_Model_DbTable_category();
	$arr = $Allcats->fetchAll();
	
	$cat = new Zend_Dojo_Form_Element_FilteringSelect('cat');
	$cat->setLabel('Select Category:');
	$cat->setAutocomplete(true);
	$cat->addValidator('NotEmpty');
	foreach ($arr as $cats){
		$cat->addMultiOption($cats->id, $cats->name);
	}
	
	
	//Course Name
	$courseName = new Zend_Dojo_Form_Element_ValidationTextBox('courseName');
	$courseName->setLabel('Enter the course Name: ');
	$courseName->setInvalidMessage('Please enter a course');
	$courseName->setRequired(true);
	$courseName->addValidator('NotEmpty');
	
	
	//Course Number
	$courseNo = new Zend_Dojo_Form_Element_ValidationTextBox('courseNo');
	$courseNo->setLabel('Enter the course number:');
	$courseNo->setRequired(true);
	$courseNo->addValidator('NotEmpty');
	
	$submit = new Zend_Dojo_Form_Element_SubmitButton('submit');
	$this->addElements(array($courseName, $courseNo,$schools, $dept, $cat,$submit));
	$this->setMethod('post');
	
 	}
 	
 }